package com.javajun.entity;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Transient;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
public class Empower {

    private Integer id;
    @JsonIgnore
    private Date startTime;
    @JsonIgnore
    private Date endTime;
    private Double payMoney;
    @JsonIgnore
    private List<Enterprise> enterprises;
    
    @Id
    @GeneratedValue
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public Date getStartTime() {
        return startTime;
    }
    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }
    public Date getEndTime() {
        return endTime;
    }
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
    public Double getPayMoney() {
        return payMoney;
    }
    public void setPayMoney(Double payMoney) {
        this.payMoney = payMoney;
    }
    
    @OneToMany(mappedBy="empower")
    public List<Enterprise> getEnterprises() {
        return enterprises;
    }
    public void setEnterprises(List<Enterprise> enterprises) {
        this.enterprises = enterprises;
    }
    
    @Transient//短暂的，表示非持久化
    public String getFormatStartTime() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        return sdf.format(startTime);
    }
    
    @Transient
    public String getFormatEndTime() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        return sdf.format(endTime);
    }
}
